package com.example.thecharacterbook;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class UpDate_PAGE extends AppCompatActivity {
    private EditText word, mean, example, example2, example3;
    private Button button;
    private String Word, Mean, Example, Word_Id,Example2,Example3;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.myupdate_page);
        Intent FATHER_intent = getIntent();
        word = findViewById(R.id.UPDATE_word);
        mean = findViewById(R.id.UPDATE_mean);
        example = findViewById(R.id.UPDATE_example);
        example2=findViewById(R.id.UPDATE_example2);
        example3=findViewById(R.id.UPDATE_example3);
        button = findViewById(R.id.UpdateBtn);
        Word = FATHER_intent.getStringExtra("Word");
        Mean = FATHER_intent.getStringExtra("Mean");
        Word_Id = FATHER_intent.getStringExtra("Word_Id");
        Log.e("ID:",Word_Id);
        Example = FATHER_intent.getStringExtra("Example");
        Example2 = FATHER_intent.getStringExtra("Example2");
        Example3 = FATHER_intent.getStringExtra("Example3");
        word.setText(Word);
        mean.setText(Mean);
        example.setText(Example);
        example2.setText(Example2);
        example3.setText(Example3);

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Log.e("ID:","success1!");
                MyDataBase db = new MyDataBase(UpDate_PAGE.this);
                Log.e("ID:","success0!");
                db.updateData(Word_Id, word.getText().toString(),
                       mean.getText().toString(),example.getText().toString(),example2.getText().toString(),example3.getText().toString());
            }
        });
    }

}


